package v1

import (
	"gin-vue-admin/global"
    "gin-vue-admin/model"
    "gin-vue-admin/model/request"
    "gin-vue-admin/model/response"
    "gin-vue-admin/service"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

// @Tags IdCardDecode
// @Summary 创建IdCardDecode
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.IdCardDecode true "创建IdCardDecode"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /idCardDecode/createIdCardDecode [post]
func CreateIdCardDecode(c *gin.Context) {
	var idCardDecode model.IdCardDecode
	_ = c.ShouldBindJSON(&idCardDecode)
	if err := service.CreateIdCardDecode(idCardDecode); err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
		response.FailWithMessage("创建失败", c)
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// @Tags IdCardDecode
// @Summary 删除IdCardDecode
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.IdCardDecode true "删除IdCardDecode"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /idCardDecode/deleteIdCardDecode [delete]
func DeleteIdCardDecode(c *gin.Context) {
	var idCardDecode model.IdCardDecode
	_ = c.ShouldBindJSON(&idCardDecode)
	if err := service.DeleteIdCardDecode(idCardDecode); err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
		response.FailWithMessage("删除失败", c)
	} else {
		response.OkWithMessage("删除成功", c)
	}
}

// @Tags IdCardDecode
// @Summary 批量删除IdCardDecode
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除IdCardDecode"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /idCardDecode/deleteIdCardDecodeByIds [delete]
func DeleteIdCardDecodeByIds(c *gin.Context) {
	var IDS request.IdsReq
    _ = c.ShouldBindJSON(&IDS)
	if err := service.DeleteIdCardDecodeByIds(IDS); err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
		response.FailWithMessage("批量删除失败", c)
	} else {
		response.OkWithMessage("批量删除成功", c)
	}
}

// @Tags IdCardDecode
// @Summary 更新IdCardDecode
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.IdCardDecode true "更新IdCardDecode"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /idCardDecode/updateIdCardDecode [put]
func UpdateIdCardDecode(c *gin.Context) {
	var idCardDecode model.IdCardDecode
	_ = c.ShouldBindJSON(&idCardDecode)
	if err := service.UpdateIdCardDecode(idCardDecode); err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
		response.FailWithMessage("更新失败", c)
	} else {
		response.OkWithMessage("更新成功", c)
	}
}

// @Tags IdCardDecode
// @Summary 用id查询IdCardDecode
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.IdCardDecode true "用id查询IdCardDecode"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /idCardDecode/findIdCardDecode [get]
func FindIdCardDecode(c *gin.Context) {
	var idCardDecode model.IdCardDecode
	_ = c.ShouldBindQuery(&idCardDecode)
	if err, reidCardDecode := service.GetIdCardDecode(idCardDecode.ID); err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(gin.H{"reidCardDecode": reidCardDecode}, c)
	}
}

// @Tags IdCardDecode
// @Summary 分页获取IdCardDecode列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdCardDecodeSearch true "分页获取IdCardDecode列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /idCardDecode/getIdCardDecodeList [get]
func GetIdCardDecodeList(c *gin.Context) {
	var pageInfo request.IdCardDecodeSearch
	_ = c.ShouldBindQuery(&pageInfo)
	if err, list, total := service.GetIdCardDecodeInfoList(pageInfo); err != nil {
	    global.GVA_LOG.Error("获取失败", zap.Any("err", err))
        response.FailWithMessage("获取失败", c)
    } else {
        response.OkWithDetailed(response.PageResult{
            List:     list,
            Total:    total,
            Page:     pageInfo.Page,
            PageSize: pageInfo.PageSize,
        }, "获取成功", c)
    }
}
